package de.barny.obj;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Shape;
import java.awt.geom.RoundRectangle2D;

import de.barny.prefs.ResourceBundleHelper;

public class Dot {

	Color dotColor;
	
	int posX;
	int posY;
	
	Dot(int pX, int pY, Color dC) {
		posX = pX;
		posY = pY;
		dotColor = dC;
	}
	
	public void paint(Graphics gameFieldGraphics) {
		Graphics2D dot = (Graphics2D)gameFieldGraphics;
		dot.setColor(dotColor);
		dot.fill(getShape());
	}
	
	private Shape getShape() {
		int dotSize = Integer.parseInt(getResource("snake.dot.size"));
		int roundness = Integer.parseInt(getResource("snake.dot.roundness"));
		RoundRectangle2D.Double shape = null;
		shape = new RoundRectangle2D.Double((posX-1)*dotSize, posY*dotSize, dotSize, dotSize, roundness, roundness);
		return shape;
	}
	
	private String getResource(String a_strResourceKey) {
		return ResourceBundleHelper.getResource(a_strResourceKey);
	}
	
	public int getPosX() {
		return posX;
	}
	
	public int getPosY() {
		return posY;
	}
	
}
